!/bin/bash
variable_1="i love you,do you want to me";
echo ${variable_1#*ov}

echo ${variable_1##*ov}

echo ${variable_1%%ov*}

echo ${variable_1/ov/OV}

echo ${variable_1//ov/OV}

echo ${#variable_1}

echo ${variable_1:5:10}

echo ${variable_1:-5}

#计算字符串的长度
echo "#######"
len1=`expr index "$variable_1" "want"`
echo $len1
echo "#######"

#计算字符串匹配
echo "#######"
len2=`expr match "$variable_1" i`
echo $len2
echo "#######"

#匹配一个子字符串
echo "#######"
len2=`expr substr "$variable_1" 5 5`
echo $len2
echo "#######"


#如果这个时候存在空格，这个时候就必须用" "括起来
expr length "$variable_1"

##########
####打印字符串的长度
####删除字符串中所有hahoop
####替换第一个hadhoop为Mapreduce
####替换全部hadoop为Mapreduce
string="Bigdata process framework is Hadoop,Hadoop is an open source project"
len3=`echo "${#string}"`
echo "String length is: $len3"

# len4=`echo "${string//hadoop/''/}"`
# echo "$len4"

# len5=`echo "${string/hadoop/Mapreduce}"`
# echo "$len5"

# len5=`echo "${string//hadoop/Mapreduce}"`
# echo "$len5"

function DelFunc 
{

    echo "${string//Hadoop/}"
}

DelFunc